<%--
  Created by IntelliJ IDEA.
  User: DELL
  Date: 2021/4/1
  Time: 15:29
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>


    <link href="${pageContext.request.contextPath}/css/bootstrap.min.css" type="text/css" rel="stylesheet">
    <script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-3.1.1.min.js"></script>
</head>
<body>

<h1 align="center">用户修改</h1>

<form class="form-horizontal">

    <div class="form-group">
        <input type="hidden" id="tId" value="${a.tId}">
        <label class="col-md-4" align="right">桌位号：</label>
        <div class="col-md-4">
            <input type="text" id="name" value="${a.tId}" class="form-control" readonly="true">
        </div>
    </div>
    <div class="form-group">
        <label class="col-md-4" align="right">人数：</label>
        <div class="col-md-4">
            <input  id="tNumber" value="${a.userNumber}" class="form-control" >
<%--            <span class="input-group-addon">此桌最多能坐${number}人</span>--%>
            <span style="font-family: 楷体;size: 1px">此桌最多能坐<span style="color: red">${number}</span>人</span>
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-4" align="right">时间：</label>
        <div class="col-md-4">

            <input type="text" value="${a.tTime}" placeholder="请选择开始时间" id="demoTest">
            <input type="text" value="${a.tArrtime}" placeholder="请选择结束时间" id="demoTestTime2">
        </div>
    </div>

    <div class="form-group">
        <label class="col-md-4"></label>
        <div class="col-md-4">
            <input type="button" class="btn btn-success btn-sm" onclick="update()" value="修改">
        </div>
    </div>

    <br>
    <span id="info"  style="color:red;position: absolute;left:30%" ></span>


</form>
</body>
<%--时间插件--%>
<script src="${pageContext.request.contextPath}/My97DatePicker/laydate/laydate.js"></script>
<script>

    laydate.render({
        elem: '#demoTest'
        ,type: 'datetime'
    });
    laydate.render({
        elem: '#demoTestTime2'
        ,type: 'datetime'
    });


</script>
<script>
    //修改方法
    function update() {
        var tId  = $("#tId").val();
        var tName  = $("#tName").val();
        var tNumber  = $("#tNumber").val();
        var demoTest  = $("#demoTest").val();
        var demoTestTime2  = $("#demoTestTime2").val();
        console.log("写入的时间为"+demoTest)
        //判断密码和确认密码是否一致
        if(tNumber == ''){
            alert("请输入桌位人数，当前桌位可坐"+${number} +"人");
        }else{
            //ajax请求
            $.ajax({
                url :"${pageContext.request.contextPath}/Reserve/ReserveUpdateAjax",
                type:"post",
                data:{"tId":tId,"tName":tName,"userNumber":tNumber,"tTime":demoTest,"tArrtime":demoTestTime2},
                contentType: "application/x-www-form-urlencoded",
                dataType:"json",
                success:function (data) {
                    console.log(data);
                    //alert(data.info);
                    $("#info").text(data.info);
                    if(data.info=="修改成功"){
                        window.location.href="${pageContext.request.contextPath}/Reserve/tableReserve1?userName=${userName}";
                    }

                }
            })
        }

    }


</script>

</html>
